import serial
import time
import signal
import sys

# 串口设置
ser = serial.Serial('COM5', 9600)
ser.timeout = 0.5  # 设置超时时间

# 发送数据
try:
    while True:
        ser.write(b'add page0.s0.id,0,100\xff\xff\xff')  # 发送数据
        # time.sleep(0.000001)  # 可根据需要调整发送间隔
except KeyboardInterrupt:  # 用户按下Ctrl+C
    print("\nCtrl+C detected. Exiting...")
    ser.close()  # 关闭串口
    sys.exit(0)
